﻿<phone:PhoneApplicationPage
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:phone="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone"
    xmlns:shell="clr-namespace:Microsoft.Phone.Shell;assembly=Microsoft.Phone"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    xmlns:viewmodel="clr-namespace:MobiSms.ViewModel;assembly=MobiSms.ViewModel"
    xmlns:toolkit="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone.Controls.Toolkit"
    xmlns:Converters="clr-namespace:MobiSms.Converters;assembly=MobiSms.Converters"
    xmlns:primitives="clr-namespace:Telerik.Windows.Controls.Primitives;assembly=Telerik.Windows.Controls.Primitives"
    xmlns:UX="clr-namespace:MobiSms.UX;assembly=MobiSms.UX"
    xmlns:es="clr-namespace:Microsoft.Expression.Shapes;assembly=Microsoft.Expression.Drawing" 
    x:Class="MobiSms.Wasun.Views.ReplyCollection"
    FontFamily="{StaticResource PhoneFontFamilyNormal}"
    FontSize="{StaticResource PhoneFontSizeNormal}"
    Foreground="{StaticResource PhoneForegroundBrush}"
    SupportedOrientations="Portrait" Orientation="Portrait"
    mc:Ignorable="d" d:DesignHeight="800" d:DesignWidth="480"
    shell:SystemTray.IsVisible="False">
    
    <phone:PhoneApplicationPage.Resources>
        <Style TargetType="ListBoxItem" x:Key="reply_itemstyle_one">
            <Setter Property="Template">
                <Setter.Value>
                    <ControlTemplate TargetType="ListBoxItem">
                        <Grid Margin="12,0">
                            <Grid.ColumnDefinitions>
                                <ColumnDefinition Width="24"/>
                                <ColumnDefinition Width="24"/>
                                <ColumnDefinition/>
                            </Grid.ColumnDefinitions>
                            <Grid>
                                <Ellipse StrokeThickness="2" 
                                                     Width="24" Height="24" 
                                                     VerticalAlignment="Top"
                                                     Margin="0,15,0,20" 
                                                     Stroke="{StaticResource PhoneAccentBrush}" />
                                <Ellipse StrokeThickness="2" 
                                                     Width="24" Height="24" 
                                                     VerticalAlignment="Top" 
                                                     Margin="0,15,0,20" 
                                                     Fill="{StaticResource PhoneAccentBrush}" 
                                                     Visibility="{Binding IsSelected, Converter={StaticResource BooleanToVisibilityConverter}, RelativeSource={RelativeSource TemplatedParent}}" />
                                <Rectangle Width="2" Height="15" Fill="{StaticResource PhoneAccentBrush}" VerticalAlignment="Top"/>
                                <Rectangle Width="2" Fill="{StaticResource PhoneAccentBrush}" Margin="0,39,0,0"/>
                            </Grid>
                            <Border Grid.Column="2"
                                                Margin="0,6,0,12" Padding="0,0,0,6" 
                                                Background="{StaticResource PhoneSubtleBrush}">
                                <StackPanel Grid.Column="1">
                                    <Grid>
                                        <Grid.ColumnDefinitions>
                                            <ColumnDefinition />
                                            <ColumnDefinition Width="auto"/>
                                        </Grid.ColumnDefinitions>
                                        <TextBlock Style="{StaticResource PhoneTextTitle2Style}"
                                                   Text="{Binding Mobile}" 
                                                   Foreground="{StaticResource PhoneChromeBrush}" 
                                                   Visibility="{Binding Status, ConverterParameter=Read, Converter={StaticResource ValueEqualsParameterToVisibilityConverter}}"/>
                                        <TextBlock Style="{StaticResource PhoneTextTitle2Style}"
                                                   Text="{Binding Mobile}" 
                                                   Foreground="{StaticResource PhoneAccentBrush}" 
                                                   Visibility="{Binding Status, ConverterParameter=Unread, Converter={StaticResource ValueEqualsParameterToVisibilityConverter}}"/>
                                        <Button Grid.Column="1" Tag="{Binding Guid}" 
                                                            Click="GotoDetailsView"
                                                            Visibility="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=IsSelected, Converter={StaticResource BooleanToVisibilityConverter}}">
                                            <Button.Style>
                                                <Style TargetType="Button">
                                                    <Setter Property="Template">
                                                        <Setter.Value>
                                                            <ControlTemplate TargetType="Button">
                                                                <Grid>
                                                                    <Grid Background="{StaticResource PhoneAccentBrush}"/>
                                                                    <Path Stretch="Uniform" Grid.Column="1"
                                                                                      Data="M33.597977,10.759002 C37.946865,10.759002 41.485962,14.285001 41.485962,18.649 C41.485962,23 37.946865,26.535 33.597977,26.535 C29.23909,26.535 25.709991,23 25.709991,18.649 C25.709991,17.784 25.849955,16.953001 26.109888,16.174002 C26.779718,16.881001 27.70948,17.327002 28.759212,17.327002 C30.778696,17.327002 32.418278,15.691001 32.418278,13.668001 C32.418278,12.663001 32.008381,11.748001 31.348551,11.087002 C32.058369,10.876001 32.818176,10.759002 33.597977,10.759002 z M33.606682,4.3679962 C25.92741,4.3679957 19.698065,10.594956 19.698065,18.27293 C19.698065,25.953894 25.92741,32.17786 33.606682,32.17786 C41.295837,32.17786 47.515175,25.953894 47.515175,18.27293 C47.515175,10.594956 41.295837,4.3679957 33.606682,4.3679962 z M34.867641,1.546141E-09 C36.890392,2.6508449E-05 58.705193,0.41938579 68.893005,18.299923 C68.893005,18.299923 57.144199,36.139835 34.44656,34.768852 C34.44656,34.768852 14.428583,36.599838 0,18.299923 C0,18.299923 9.0791521,0.4590019 34.716553,0.0010111886 C34.716553,0.0010114873 34.768162,-1.4442128E-06 34.867641,1.546141E-09 z"
                                                                                      Fill="White"
                                                                                      Width="30"
                                                                                      Margin="6"
                                                                                      VerticalAlignment="Center" HorizontalAlignment="Right"  
                                                                                      RenderTransformOrigin="0.5,0.5">
                                                                        <Path.RenderTransform>
                                                                            <TransformGroup>
                                                                                <TransformGroup.Children>
                                                                                    <RotateTransform Angle="0" />
                                                                                    <ScaleTransform ScaleX="1" ScaleY="1" />
                                                                                </TransformGroup.Children>
                                                                            </TransformGroup>
                                                                        </Path.RenderTransform>
                                                                    </Path>
                                                                </Grid>
                                                            </ControlTemplate>
                                                        </Setter.Value>
                                                    </Setter>
                                                </Style>
                                            </Button.Style>
                                        </Button>
                                    </Grid>
                                    <TextBlock Style="{StaticResource PhoneTextNormalStyle}" Text="{Binding DisplayContent}" TextWrapping="Wrap"/>
                                </StackPanel>
                            </Border>
                            <es:BlockArrow Fill="{StaticResource PhoneSubtleBrush}" 
                                                       Margin="0,15,-8,0" 
                                                       Orientation="Left" 
                                                       UseLayoutRounding="False" 
                                                       StrokeThickness="0" 
                                                       Grid.Column="1" 
                                                       ArrowheadAngle="12" 
                                                       Width="16" Height="24" 
                                                       VerticalAlignment="Top"/>
                        </Grid>

                    </ControlTemplate>
                </Setter.Value>
            </Setter>
        </Style>
        
        <Style TargetType="ListBoxItem" x:Key="reply_itemstyle_two">
        	<Setter Property="Template">
        		<Setter.Value>
        			<ControlTemplate TargetType="ListBoxItem">
                        <Grid Margin="12,0,12,24">
                            <Button Tag="{Binding Guid}" Click="GotoDetailsView">
                                <Button.Style>
                                    <Style TargetType="Button">
                                        <Setter Property="Template">
                                            <Setter.Value>
                                                <ControlTemplate TargetType="Button">
                                                    <StackPanel>
                                                        <Grid Margin="0, 0, 0, 12"
                                                              HorizontalAlignment="Left">
                                                            <TextBlock Style="{StaticResource PhoneTextTitle2Style}"
                                                                       Text="{Binding Mobile}" 
                                                                       Margin="0"
                                                                       Foreground="{StaticResource PhoneChromeBrush}" 
                                                                       Visibility="{Binding Status, ConverterParameter=Read, Converter={StaticResource ValueEqualsParameterToVisibilityConverter}}"/>
                                                            <TextBlock Style="{StaticResource PhoneTextTitle2Style}"
                                                                       Text="{Binding Mobile}" 
                                                                       Margin="0"
                                                                       Foreground="{StaticResource PhoneAccentBrush}" 
                                                                       Visibility="{Binding Status, ConverterParameter=Unread, Converter={StaticResource ValueEqualsParameterToVisibilityConverter}}"/>
                                                        </Grid>

                                                        <primitives:RadPointerContentControl Background="{StaticResource PhoneAccentBrush}"
                                                                 TargetPoint="-120,-300"
                                                                 Foreground="White">
                                                            <primitives:RadPointerContentControl.PointerTemplate>
                                                                <DataTemplate>
                                                                    <Polygon Width="12"
                                                                         Height="24"
                                                                         Points="0,0 12,0 12,12 0,24"
                                                                         StrokeThickness="0"
                                                                         Fill="{StaticResource PhoneAccentBrush}"
                                                                         RenderTransformOrigin="0.5, 0.5">
                                                                        <Polygon.RenderTransform>
                                                                            <ScaleTransform ScaleX="-1"/>
                                                                        </Polygon.RenderTransform>
                                                                    </Polygon>
                                                                </DataTemplate>
                                                            </primitives:RadPointerContentControl.PointerTemplate>

                                                            <TextBlock Text="{Binding DisplayContent}"
                                                                       Style="{StaticResource PhoneTextNormalStyle}"
                                                                       TextWrapping="Wrap"
                                                                       Margin="12"/>

                                                        </primitives:RadPointerContentControl>
                                                    </StackPanel>
                                                </ControlTemplate>
                                            </Setter.Value>
                                        </Setter>
                                    </Style>
                                </Button.Style>
                            </Button>
                        </Grid>
                    </ControlTemplate>
        		</Setter.Value>
        	</Setter>
        </Style>

        <Style TargetType="ListBoxItem" x:Key="month_itemstyle">
            <Setter Property="HorizontalContentAlignment" Value="Right"/>
            <Setter Property="Template">
                <Setter.Value>
                    <ControlTemplate TargetType="ListBoxItem">
                        <Grid Margin="0,0,0,24" HorizontalAlignment="Right">
                            <Grid.ColumnDefinitions>
                                <ColumnDefinition />
                                <ColumnDefinition Width="12"/>
                            </Grid.ColumnDefinitions>
                            <VisualStateManager.VisualStateGroups>
                                <VisualStateGroup x:Name="SelectionStates">
                                    <VisualStateGroup.Transitions>
                                        <VisualTransition GeneratedDuration="0:0:0.4"/>
                                    </VisualStateGroup.Transitions>
                                    <VisualState x:Name="Unselected"/>
                                    <VisualState x:Name="Selected">
                                        <Storyboard>
                                            <DoubleAnimation Duration="0" To="0" Storyboard.TargetProperty="(UIElement.Opacity)" Storyboard.TargetName="textNormal" d:IsOptimized="True"/>
                                            <DoubleAnimation Duration="0" To="1" Storyboard.TargetProperty="(UIElement.Opacity)" Storyboard.TargetName="textSelected" d:IsOptimized="True"/>
                                        </Storyboard>
                                    </VisualState>
                                    <VisualState x:Name="SelectedUnfocused"/>
                                </VisualStateGroup>
                            </VisualStateManager.VisualStateGroups>
                            <TextBlock x:Name="textNormal"
                                                   Text="{Binding Converter={StaticResource EnumTranslateConverter}}" 
                                                   Opacity="1"/>
                            <TextBlock x:Name="textSelected" 
                                                   Text="{Binding Converter={StaticResource EnumTranslateConverter}}" 
                                                   Foreground="{StaticResource PhoneAccentBrush}" 
                                                   Opacity="0"/>

                            <Rectangle Grid.Column="1" Width="2" 
                                                   HorizontalAlignment="Right" 
                                                   Margin="0,3" 
                                                   Fill="{StaticResource PhoneAccentBrush}" 
                                                   Visibility="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=IsSelected, Converter={StaticResource BooleanToVisibilityConverter}}" />
                        </Grid>
                    </ControlTemplate>
                </Setter.Value>
            </Setter>
        </Style>
    </phone:PhoneApplicationPage.Resources>
   
    <Grid x:Name="LayoutRoot">
        <Grid.Background>
            <ImageBrush ImageSource="{Binding GlobalSettings.BackgroundImage}" Stretch="{Binding GlobalSettings.BackgroundImageStretch}" />
        </Grid.Background>
        <Grid.DataContext>
            <viewmodel:ReplyViewModel/>
        </Grid.DataContext>
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto"/>
            <RowDefinition Height="*"/>
        </Grid.RowDefinitions>

        <StackPanel x:Name="TitlePanel" Grid.Row="0" Margin="12,17,0,28">
            <TextBlock Text="{StaticResource IDS_APP_NAME}" Style="{StaticResource PhoneTextNormalStyle}"/>
            <TextBlock Text="{StaticResource IDS_REPLY_COLLECTION_TITLE}" Margin="9,-7,0,0" Style="{StaticResource PhoneTextTitle1Style}"/>
        </StackPanel>

        <Grid Grid.Row="1" Margin="12,0,12,0">
            <Grid.RowDefinitions>
                <RowDefinition/>
                <RowDefinition Height="auto"/>
            </Grid.RowDefinitions>

            <ListBox ItemsSource="{Binding ItemsOfReply}" ItemContainerStyle="{StaticResource reply_itemstyle_two}" />

            <TextBlock Style="{StaticResource PhoneTextTitle3Style}" 
                       Text="{StaticResource IDS_COMMON_NODATA}" 
                       Visibility="{Binding ItemsOfReply.Count, Converter={StaticResource NumberEqualsParameterToVisibilityConverter}, ConverterParameter=0}"/>

            <Grid Grid.Row="1">
                <Grid.ColumnDefinitions>
                    <ColumnDefinition/>
                    <ColumnDefinition Width="auto"/>
                </Grid.ColumnDefinitions>

                <TextBlock VerticalAlignment="Center" Style="{StaticResource PhoneTextTitle2Style}">
                    <Run Text="{Binding ItemsOfReply.Count}" />
                    <Run Text=" / " />
                    <Run Text="{Binding ItemsCount, Mode=OneWay}" />
                </TextBlock>

                <UX:UXPathButton Grid.Row="1"
                                 Grid.Column="1"
                                 Margin="12"
                                 Command="{Binding LoadPreviousCommand,
                                                   Mode=OneWay}"
                                 IconPath="{StaticResource PATH_ICON_DOWN}" />
            </Grid>
        </Grid>
    </Grid>
 
</phone:PhoneApplicationPage>
